﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Client
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            p2p.GlobalCmdBackground globalCmdBg = new p2p.GlobalCmdBackground();
            UpdateUserDataForm updateUserDataForm = new UpdateUserDataForm(globalCmdBg);
            updateUserDataForm.ShowDialog();

            UserSession session = new UserSession();
            UserData userdata = new UserData();
            userdata.ReadDb();

            LoginForm loginForm = new LoginForm(session, userdata, globalCmdBg);
            DialogResult result = loginForm.ShowDialog();
            if (result == DialogResult.Cancel)
                return;

            globalCmdBg.Session = session;
            p2p.MessageProcessor msgPro = new p2p.MessageProcessor(globalCmdBg, userdata, session);
            Client client = new Client(session, userdata, msgPro);
            Application.Run(client);
        }
    }
}